<#assign module="marketing"/>

<@override name="header">
</@override>
<@override name="body">

<div class="row">
	<div class="col-xs-10">
	  	<div class="btn-group">
		  <a class="btn btn-default active" href="${ctx}/weixinmanager/list">客户经理</a>
		  <a class="btn btn-default" href="${ctx}/weixinmanager/agreement">合作协议</a>
		  <a class="btn btn-default" href="${ctx}/weixinmanager/tixian">提现审核 <span class="label label-danger" id="wait_audit_label"></span></a>
		</div>
	</div>
 	<div class="col-xs-2">
 		<button class="pull-right btn btn-primary" onclick="window.location='${ctx}/weixinmanager/add';"><i class="icon-plus"></i>&nbsp;添加客户经理</button>
	</div>
</div>

<div class="row margin-top">
	<div class="col-xs-12">
		<form class="form-inline" role="form">
		
		  	<div class="form-group">
		  		<input type="text" class="form-control" style="width:250px;" name="name" value="${name?if_exists}" placeholder="姓名">
		  	</div>
		  	
		  	<div class="form-group">
		  		<input type="text" class="form-control" style="width:250px;" name="phone" value="${phone?if_exists}" placeholder="电话号码">
		  	</div>
		  	
		  	<div class="form-group">
		  		<input type="text" class="form-control" style="width:250px;" name="placeName" value="${placeName?if_exists}" placeholder="工作单位名称">
		  	</div>
		  	
			<div class="form-group">
		  		<input type="text" class="form-control" style="width:250px;" name="idCard" value="${idCard?if_exists}" placeholder="身份证号">
		  	</div>
		  	
		  	<@shiro.isMainCompany>
				<select class="form-control" name="companyId" id="companyId">
					<option value="">全部公司</option>
		  			<#list companys as company>
		  				<option value="${company.id}" <#if companyId?? && companyId==company.id>selected="selected"</#if>>${company.abbreviation}</option>
		  			</#list>
	  			</select>
			</@shiro.isMainCompany>
			
			<div class="form-group">
				<select class="form-control" data-val="true"  name="virtualType">
					<option value="">不使用余额排序</option>
					<option value="1" <#if virtualType?? && virtualType==1>selected="selected"</#if>>余额从大到小排序</option>
					<option value="2" <#if virtualType?? && virtualType==2>selected="selected"</#if>>余额从小到大排序</option>
				</select>
		    </div>
		  	
		  	<button id="search_button" type="submit" class="btn btn-primary"><i class="icon-search"></i>&nbsp;搜索</button>
		</form>
	</div>
</div>

<div class="row margin-top">
	<div class="col-xs-12">
	<div class="panel panel-primary">
	<div class="table-responsive">
		<table class="table table-hover table-striped">
			<thead>
			<tr style="font-size:14px;">
				<th>状态</th>
				<th>姓名</th>
				<th>电话号码</th>
				<th>微信号</th>
				<@shiro.isMainCompany>
				<th>所属公司</th>
				</@shiro.isMainCompany>
				<th>工作单位名称</th>
				<th>身份证</th>
				<th>余额</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
				<#if (page.content)?? >
			  	<#list page.content as data>
					<tr>
						<td>
							<#if data.status==0>
								<span class="label label-info">待审核</span>
							<#elseif data.status==1>
								<span class="label label-success">已通过</span>
							<#elseif data.status==2>
								<span class="label label-warning">未通过</span>
							</#if>
						</td>
						<td>${data.name?if_exists}</td>
						<td>${data.phone?if_exists}</td>
						<td>${data.wxAccount?if_exists}</td>
						<@shiro.isMainCompany>
						<td>
							<#if data.company??>
								${data.company.abbreviation?if_exists}
							</#if>
						</td>
						</@shiro.isMainCompany>
						<td>${data.placeName?if_exists}</td>
						<td>${data.idCard?if_exists}</td>
						<td>${data.virtual?if_exists}</td>
						<td>
							<#if data.status==1>
								<a href="${ctx}/weixinmanager/edit/${data.id}" class="btn-link">编辑</a>
								<a href="${ctx}/weixinmanager/orderRecord/${data.id}" class="btn-link">下单记录</a>
							</#if>
							<#if data.status==0>
								<a href="${ctx}/weixinmanager/audit/${data.id}" class="btn-link">审核</a>
							</#if>
							<a href="javascript:;" data-value="${data.id}" class="btn-link deletethis">删除</a>
						</td>
					</tr>
				</#list>
				</#if>
			</tbody>
		</table>
		<#if page.totalElements??>
		<ul class="pagination pull-right pagination-sm">
			<li><a>共 ${page.totalElements} 条数据</a></li>
			<@pg.pager items=page.totalElements?number maxPageItems=20 export="currentPageNumber=pageNumber" url="${ctx}/weixinmanager/list">
				<@pg.param name="phone" value="${phone?if_exists}"/>
				<@pg.param name="name" value="${name?if_exists}"/>
				<@pg.param name="placeName" value="${placeName?if_exists}"/>
				<@pg.param name="idCard" value="${idCard?if_exists}"/>
				<@pg.param name="companyId" value="${companyId?if_exists}"/>
				<@pg.param name="virtualType" value="${virtualType?if_exists}"/>
				<@pg.index>
					<@pg.first>
						<li><a href="${pageUrl}">&laquo;</a></li>
					</@pg.first>
					<@pg.prev>
						<li><a href="${pageUrl}">&lsaquo;</a></li>
					</@pg.prev>
					<@pg.pages>
						<#if  currentPageNumber == pageNumber >
							<li class="active"><a href="#">${pageNumber}</a></li>
						<#else>
							<li><a href="${pageUrl}">${pageNumber}</a></li>
						</#if>
					</@pg.pages>
					<@pg.next>
						<li><a href="${pageUrl}">&rsaquo;</a></li>
					</@pg.next>
					<@pg.last>
						<li><a href="${pageUrl}">&raquo;</a></li>
					</@pg.last>
				</@pg.index>
			</@pg.pager>
		</ul>
		</#if>
	</div>
	</div>
	</div>
</div>
</@override>
<@override name="footer">
<script src="${ctx}/assets/js/weixinmanager/managercommon.js"></script>
<script type="text/javascript">
	var thisButton;
	function deleteWeixinManager() {
	    $.post('${ctx}/weixinmanager/delete',{'id':thisButton.attr("data-value")},function(data){
            if(data.success){
            	thisButton.parent().parent().remove();
                $.scojs_message('客户经理删除成功', $.scojs_message.TYPE_OK);
            } else {
                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
            }
	    },'json');
	}
	$(document).ready(function(){
	    $(".deletethis").click(function(){
	          thisButton = $(this);
	          var confirm = $.scojs_confirm({
	            content: "你真的要删除该客户经理吗？",
	            action:deleteWeixinManager
	          });
	          confirm.show();
	    });
	});
</script>
</@override>
<@extends name="../layout.ftl"/>